/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
 */

package app.controllers.merchant;

import app.interceptors.merchant.CommonInterceptor;
import com.github.sog.controller.BasicController;
import com.github.sog.controller.security.SecurityKit;
import com.jfinal.aop.Before;
import com.jfinal.aop.ClearInterceptor;
import com.jfinal.core.ActionKey;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * .
 * </p>
 *
 * @author sagyf yang
 * @version 1.0 2014-05-25 11:09
 * @since JDK 1.6
 */

public class MainController extends BasicController {

    /**
     * The index route.
     */
    @Before(CommonInterceptor.class)
    public void index() {
        render("index.ftl");
    }


    @ActionKey("/merchant/logout")
    @ClearInterceptor
    public void logout() {
        final HttpServletRequest request = getRequest();
        boolean subject = SecurityKit.isLogin(request);
        if (subject) {
            SecurityKit.logout(request, getResponse());
        }
        redirect("/merchant/login");
    }
}